#include <windows.h>
#include <stdio.h>

int main (int argc, char* argv[])  {

	if (1 >= argc) {
		printf("Kill is used to terminate a process\n");
		printf("\n");
		printf("Usage:\tkill <pid>\n");
		printf("\n");
		printf("Parameters:\n");
		printf("pid\tthe process id\n");
		return -1;
	}

	long pid = atol(argv[1]);

    HANDLE process = OpenProcess(
        PROCESS_TERMINATE,
        FALSE,
        pid
    );

    if( !process )
        return GetLastError();

    DWORD status;
    if( TerminateProcess(process, 0) )
        status = ERROR_SUCCESS;
    else
        status = GetLastError();

    CloseHandle(process);

	return 0;
}






